reorded function definitions
removed double declaration