simplified code, kept the same functionality.