Use utils file

These functions are reused so we can put them on a utils file