implement routes middleware