Refactor filter function
Few bug fixes on Android 4.1