Fixed errors based on test cases