Fixed some error around the code