Coding for algorithm