improvement on last commit making further generalisation possible