Removed unused code and made function static