Solved issues with function declaration at runtime