Fixed bug and removed unrequired code