preventing scope nonsense, moving function declaration