Fixing PHP notices
Fixing fatal error because functions were moved in a function