diff --git a/app/controllers/team_members_controller.rb b/app/controllers/team_members_controller.rb
index 7e4c8792b502346defa63f57c15e0f825f8e9333..18d4ae3ac96df8fde06d01d54aaa1bc72e59f26f 100644
--- a/app/controllers/team_members_controller.rb
+++ b/app/controllers/team_members_controller.rb
@@ -39,7 +39,7 @@ class TeamMembersController < ProjectResourceController
   end
 
   def destroy
-    @user_project_relation = project.users_projects.find_by_user_id(params[:id])
+    @user_project_relation = project.users_projects.find_by_user_id(member)
     @user_project_relation.destroy
 
     respond_to do |format|
@@ -59,6 +59,6 @@ class TeamMembersController < ProjectResourceController
   protected
 
   def member
-    @member ||= User.find(params[:id])
+    @member ||= User.find_by_username(params[:id])
   end
 end