got rid of code duplication and relaxed argument checking rules