Code revised a little bit