reversed functions done, just need to add flag identifier