Process flow is clear, next is to write code for algorthm