added functions for calculating coterminals