updated code to nicer syntax