some changes to shorten the code