implemented compact function