this is all the general code (.m only)