refactored the compact method to push instead of splice the original inp...

...ut array