You are right, will remove these functions from here and simplify the code a little bit