simplfied the code