Fixing custom function