started max margin code