refactor gcc function for server side