implementing Rick's modifications