abstracted and simplified code