modified by jayli for bugfix