Add function is not working properly