takes more stuff as arguments also cleaned the code a bit