If you want to program then you should flow chart it.