updated code to become more clear